package com.lineage.data.item_armor.set;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SkillHaste;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;

public class EffectHaste implements ArmorSetEffect {
  private final int _add;
  
  public EffectHaste(int add) {
    this._add = add;
  }
  
  public void giveEffect(L1PcInstance pc) {
    pc.addHasteItemEquipped(this._add);
    pc.removeHasteSkillEffect();
    pc.sendPackets((ServerBasePacket)new S_SkillHaste(pc.getId(), 1, -1));
    if (pc.getMoveSpeed() != 1) {
      pc.setMoveSpeed(1);
      pc.broadcastPacketAll((ServerBasePacket)new S_SkillHaste(pc.getId(), 1, 0));
    } 
    if (pc.getarmor_setgive())
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("套装效果[绿水状态]")); 
  }
  
  public void cancelEffect(L1PcInstance pc) {
    pc.addHasteItemEquipped(-this._add);
    if (pc.getHasteItemEquipped() == 0) {
      pc.setMoveSpeed(0);
      pc.sendPacketsAll((ServerBasePacket)new S_SkillHaste(pc.getId(), 0, 0));
    } 
    if (pc.getarmor_setgive())
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("移除套装效果[绿水状态]")); 
  }
  
  public int get_mode() {
    return this._add;
  }
}
